package com.zzw.util;

import java.net.InetAddress;

import ch.qos.logback.classic.pattern.ClassicConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
/**
* @Athor:xiezhongjiang
* @Description:logback ipconvert
* @Date:2017/10/30 10:31
* @Since:1.0.0
*/
public class IpConvert extends ClassicConverter {  
	  
    @Override  
    public String convert(ILoggingEvent event) {
    	String ip = "";
        InetAddress ia=null;
        try {
        	ia = InetAddress.getLocalHost();
            String localname=ia.getHostName();
            String localip=ia.getHostAddress();
            ip+="["+localname+"|"+localip;
        } catch (Exception e) {
            e.printStackTrace();
        }  
        return ip;
    }  
}  
